package com.jnxx.okr.service.impl;

import com.jnxx.okr.domain.Kr;
import com.jnxx.okr.domain.Renew;
import com.jnxx.okr.mapper.KrMapper;
import com.jnxx.okr.mapper.RenewMapper;
import com.jnxx.okr.service.IKrService;
import com.jnxx.basic.service.impl.BaseServiceImpl;
import com.jnxx.task.domain.Task;
import com.jnxx.task.mapper.TaskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务实现类：
 */
@Service
public class KrServiceImpl extends BaseServiceImpl<Kr> implements IKrService {

    @Autowired
    private KrMapper krMapper;
    @Autowired
    private TaskMapper taskMapper;
    @Autowired
    private RenewMapper renewMapper;

    @Override
    public Kr getKrDetailById(Long id) {
        Kr kr = super.findOne(id);
        List<Task> taskList = taskMapper.findByKrId(id);
        if (taskList.size() > 0){
            kr.setTaskList(taskList);
        }
        List<Renew> renewList = renewMapper.findByOkrId(id);
        if (renewList.size() > 0){
            kr.setRenewList(renewList);
        }
        return kr;
    }
}
